// 验证规则
$('#changePW').validate({
    rules: {
        nowPW: {
            required: true,
            password: true
        },
        newPW: {
            required: true,
            password: true
        },
        prNewPW: {
            required: true,
            equalTo: '#newPW'
        },
        jyNowPW: {
            required: true,
            password: true
        },
        jyNewPW: {
            required: true,
            password: true
        },
        prJyNewPW: {
            required: true,
            equalTo: '#jyNewPW'
        }
    },
    messages: {
        nowPW: {
            required: "不能为空"
        },
        newPW: {
            required: "不能为空"
        },
        prNewPW: {
            required: "不能为空",
            equalTo: "两次输入密码不一致"
        },
        jyNowPW: {
            required: "不能为空"
        },
        jyNewPW: {
            required: "不能为空"

        },
        prJyNewPW: {
            required: "不能为空",
            equalTo: "两次输入密码不一致"
        }
    },
    errorPlacement: function (error, element) {
        $(element).siblings('.u-ts').html(error)
    },
    errorElement: 'span',
    submitHandler: function (form) {
        form.submit();
    }
});

jQuery.validator.addMethod('password', function (value, element) {
    var password = /^[a-z0-9_-]{6,18}$/.test(value);
    return this.optional(element) || password
}, '请输入6-18位字母，数字_-');


